package com.neu.af.controller;

import com.neu.af.common.base.BaseController;
import com.neu.af.common.base.BaseModel;
import com.neu.af.util.DBUtil;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/DBOp")
public class DBController extends BaseController {

    @GetMapping("/backupDB")
    public BaseModel backupDB() {
        String command =
                "mysql -hlocalhost -uroot -p123456 alarmfilter < C:\\alarm\\backup.sql";
//        String command =
//        "mysql -hlocalhost -uroot -proot alarmfilter < //home//administrator//alarmfilter//backupfile.sql";
//        String command =
//                "find /home/administrator/alarmfilter"; // 成功
//        String command =
//                "mysql -hlocalhost -uroot -proot alarmfilter < /home/administrator/alarmfilter/backupfile.sql";
        Boolean flag =  DBUtil.cmd("cmd.exe /C "+ command);
        BaseModel result = new BaseModel();
        result.code = 200;
        if (flag) result.message = "还原默认配置成功";
        else result.message = "还原默认配置失败";
        return result;
    }
}






